One of the most exciting things you can do with Custom Event Transformers is to enhance events based on arbitrary calculations. The example I wrote in the docs calculates “Is an Instagram post labelled cute?”, but you could just as easily write “If load >50% but <90% then attache Runbook A, if it’s >90% attach Runbook B”
var webhook = PD.inputRequest.body;
var normalized_event = {
event_type: PD.Trigger,
description: 'Incoming kitten from ' + webhook.user.username,
client: 'Instagram',
client_url: webhook.link,
contexts: [{
type: 'image',
src: webhook.images.standard_resolution.url,
href: webhook.link,
alt: webhook.caption.text
}]
};
if (webhook.caption.text.indexOf('cute') > -1) {
normalized_event.contexts.push({
type: 'link',
href: 'https://broadly.vice.com/en_us/article/why-you-are-addicted-to-cute-baby-animals',
text: '[Runbook] How to handle cuteness overload'
});
}
PD.emitGenericEvents([normalized_event]);